package com.danjoas.interceptor;

import org.aspectj.lang.JoinPoint;
import org.aspectj.lang.annotation.After;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Before;
import com.danjoas.model.Autor;

/**
 *
 * @author Dan Joas
 */
@Aspect
public class AuditoriaInterceptor {

    @Before("execution(* com.danjoas.service.impl.AutorServiceImpl.insert(com.danjoas.model.Autor)) && args(autor)")
    public void beforeInsertAutor(Autor autor) {
        System.out.println("AUDITORIA : antes de insertar autor :  " + autor);
    }

    @After("execution(* com.danjoas.service.impl.AutorServiceImpl.update(com.danjoas.model.Autor)) && args(autor)")
    public void afterActualizarAutor(Autor autor) {
        System.out.println("AUDITORIA : luego de actualizar autor : " + autor);
    }

    public void beforeEliminarAutor(JoinPoint joinPoint) {
        System.out.println("AUDITORIA : antes de eliminar autor : " + joinPoint.getArgs()[0]);
    }
}
